package com.newsmanagement.dao;

import com.newsmanagement.entity.NewsContentEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author xbr
 * 2017/12/5
 * 社会动态操作
 */
@Mapper
public interface IResourceServiceDao {

    /**
     * 添加资源
     * @param userId 操作人id
     * @param resourceName 资源名称
     * @param resourceInfo 资源内容
     */
    @Insert("INSERT INTO resource_t( " +
            "RESOURCE_INFO ,  RESOURCE_NAME , CREATE_USER , CREATE_DATE , UPDATE_USER , UPDATE_DATE" +
            ") VALUES (" +
            "#{arg2} ,#{arg1} ,#{arg0} ,NOW() ,#{arg0} ,NOW())")
    void saveResource(Integer userId ,String resourceName ,String resourceInfo);

    /**
     * 修改资源
     * @param userId 操作人id
     * @param resourceId 资源id
     * @param resourceName 资源名称
     * @param resourceInfo 资源内容
     */
    @Update("UPDATE resource_t SET  " +
            "RESOURCE_INFO = #{arg3} ,  RESOURCE_NAME = #{arg2} , UPDATE_USER = #{arg0} ,UPDATE_DATE = NOW() " +
            "WHERE RESOURCE_ID = #{arg1}")
    void updateResource(Integer userId , Integer resourceId ,String resourceName ,String resourceInfo);

    /**
     * 删除资源
     * @param userId 操作人id
     * @param resourceId 资源id
     */
    @Update("UPDATE resource_t SET DELETE_FLAG = 0 ,UPDATE_USER = #{arg0} ,UPDATE_DATE = NOW() WHERE RESOURCE_ID = #{arg1}")
    void deleteResource(Integer userId , Integer resourceId);


}
